from sklearn.neighbors import KNeighborsClassifier
import pandas as pd

def knnclas():
    """
    预测每个人签到位置
    :return:
    """
    #读取数据
    data = pd.read_csv("train.csv")
    print(data.head(10))
    # 处理数据

    #缩小数据的范围
    data = data.query("x>1.0 & x<1.25 & y>2.5 &y<2.75") #相当于查询语句
    # 处理时间
    time_value = pd.to_datetime(data['time'],unit='s')
    print(time_value)
    #把日期格式转换成字典格式
    time_value = pd.DatetimeIndex(time_value)

    # 构造一些特征
    data['day']=time_value.day
    data['hour'] = time_value.hour
    data['weekday']= time_value.weekday
    # 把时间戳特征删除  axis=1是删除列
    data = data.drop(['time'],axis=1)
    print(data)
    # 特征处理

if __name__ =='__main__':
    knnclas()